package com.deyuanyun.pic.ctrl.controller.dto;

import com.deyuanyun.pic.common.spring.SpringAppliction;
import com.deyuanyun.pic.common.util.ObjectUtil;
import com.deyuanyun.pic.common.util.poi.annotation.ExcelWriteColumn;
import com.deyuanyun.pic.ctrl.enumeration.InfluencePositionEnum;
import com.deyuanyun.pic.ctrl.mapper.EqptCptestStationMapper;

import java.math.BigDecimal;
import java.util.Date;

/**
 * @author Jerry
 * @Description 直流牵引系统系统干扰源dto
 * @date 2016-09-07
 */
public class InfluenceActowDTO {
    /**
     * 主键
     */
    private String id;

    /**
     * 创建时间
     */
    private Date createDate;

    /**
     * 创建人
     */
    private String createUser;

    /**
     * 创建备注
     */
    private String createRemark;

    /**
     * 更新时间
     */
    private Date updateDate;

    /**
     * 更新人员
     */
    private String updateUser;

    /**
     * 更新原因
     */
    private String updateRemark;

    /**
     * 逻辑删除字段
     */
    private Short deleted;

    /**
     * 版本
     */
    private Short version;

    /**
     * 是否是最新数据，0：最新数据；1：历史数据
     */
    private Short isNewest;

    /**
     * 数据状态
     */
    private String dataStated;

    /**
     * 管道id
     */
    private String pipeLineId;

    /**
     * 所属管道
     */
    @ExcelWriteColumn
    private String pipeName;

    /**
     * 统一编号
     */
    private String code;

    /**
     * 设备编号(自定义编号)
     */
    @ExcelWriteColumn
    private String customNumber;

    /**
     * 干扰源名称
     */
    @ExcelWriteColumn
    private String name;

    /**
     * 相对位置关系(平行PARALLEL、交叉ACROSS)
     */
    @ExcelWriteColumn
    private String relativePositionRelation;


    /**
     * GISID
     */
    private String gisid;

    /**
     * 平行段起点_绝对里程
     */
    @ExcelWriteColumn
    private String beginMileage;

    /**
     * 平行起点_附近测试桩
     */
    private String beginNagm;
    @ExcelWriteColumn
    private String pbeginNgm;


    /**
     * 平行起点_附近测试桩距离
     */
    @ExcelWriteColumn
    private String beginNagmMileage;

    /**
     * 平行段终点_绝对里程
     */
    @ExcelWriteColumn
    private String endMileage;

    /**
     * 平行段终点_附近测试桩
     */

    private String endNagm;
    @ExcelWriteColumn
    private String pendNgm;

    /**
     * 平行段终点_附近测试桩距离
     */
    @ExcelWriteColumn
    private String endNagmMileage;

    /**
     * 最小平行间距
     * （m）
     */
    @ExcelWriteColumn
    private BigDecimal minDistance;

    /**
     * 平行距离（由系统计算，终点距离-起点距离）
     */
    @ExcelWriteColumn
    private BigDecimal parallelMileage;

    /**
     * 交叉段_绝对里程
     */
    @ExcelWriteColumn
    private String crossMileage;

    /**
     * 交叉段_附近测试桩
     */
    private String crossNagm;
    @ExcelWriteColumn
    private String crossNgm;

    /**
     * 交叉段_附近测试桩距离
     */
    @ExcelWriteColumn
    private String crossNagmMileage;

    /**
     * 位置描述
     */
    @ExcelWriteColumn
    private String locationDescription;

    /**
     * 投用日期
     */
    @ExcelWriteColumn
    private Date inserviceDate;

    /**
     * 供电方式
     */
    @ExcelWriteColumn
    private String powerSupplyMode;

    /**
     * 馈电方式
     */
    @ExcelWriteColumn
    private String feedMode;

    /**
     * 馈电极性
     */
    @ExcelWriteColumn
    private String feedElectrodeProperty;

    /**
     * 牵引电流（A）
     */
    @ExcelWriteColumn
    public Long tractionCurrent;

    /**
     * 牵引变电所_X
     */
    private BigDecimal substationX;

    /**
     * 牵引变电所_Y
     */
    private BigDecimal substationY;

    /**
     * 牵引变电所_Z
     */
    private BigDecimal substationZ;

    /**
     * 牵引变电所_附近测试桩
     */
    private String substationNagm;

    /**
     * 牵引变电所_附近测试桩距离
     */
    public Long substationNagmMileage;

    /**
     * 牵引变电所_绝对里程
     */
    public Long substationMileage;

    /**
     * 距管道最小距离（m）
     */
    @ExcelWriteColumn
    private BigDecimal minDistanceFromPipe;

    /**
     * 牵引变电所位置描述
     */
    @ExcelWriteColumn
    private String substationLocationDesc;

    /**
     * 电车运行状况
     */
    @ExcelWriteColumn
    private String runningStatusOfTram;

    /**
     * 检测日期
     */
    @ExcelWriteColumn
    private Date testingDate;

    /**
     * 检测单位
     */
    @ExcelWriteColumn
    private String testingCompany;

    /**
     * 记录人（直接存名称）
     */
    @ExcelWriteColumn
    private String recorder;

    /**
     * 记录时间
     */
    @ExcelWriteColumn
    private Date recordTime;

    /**
     * 备注
     */
    @ExcelWriteColumn
    private String remarks;

    /**
     * 业务组织路径
     */
    private String orgBizPath;

    /**
     * 管道gisid
     */
    private String pipeGisId;


    /**
     * @return 主键
     */
    public String getId() {
        return id;
    }

    /**
     * @param id 主键
     */
    public void setId(String id) {
        this.id = id == null ? null : id.trim();
    }

    /**
     * @return 创建时间
     */
    public Date getCreateDate() {
        return createDate;
    }

    /**
     * @param createDate 创建时间
     */
    public void setCreateDate(Date createDate) {
        this.createDate = createDate;
    }

    /**
     * @return 创建人
     */
    public String getCreateUser() {
        return createUser;
    }

    /**
     * @param createUser 创建人
     */
    public void setCreateUser(String createUser) {
        this.createUser = createUser == null ? null : createUser.trim();
    }

    /**
     * @return 创建备注
     */
    public String getCreateRemark() {
        return createRemark;
    }

    /**
     * @param createRemark 创建备注
     */
    public void setCreateRemark(String createRemark) {
        this.createRemark = createRemark == null ? null : createRemark.trim();
    }

    /**
     * @return 更新时间
     */
    public Date getUpdateDate() {
        return updateDate;
    }

    /**
     * @param updateDate 更新时间
     */
    public void setUpdateDate(Date updateDate) {
        this.updateDate = updateDate;
    }

    /**
     * @return 更新人员
     */
    public String getUpdateUser() {
        return updateUser;
    }

    /**
     * @param updateUser 更新人员
     */
    public void setUpdateUser(String updateUser) {
        this.updateUser = updateUser == null ? null : updateUser.trim();
    }

    /**
     * @return 更新原因
     */
    public String getUpdateRemark() {
        return updateRemark;
    }

    /**
     * @param updateRemark 更新原因
     */
    public void setUpdateRemark(String updateRemark) {
        this.updateRemark = updateRemark == null ? null : updateRemark.trim();
    }

    /**
     * @return 逻辑删除字段
     */
    public Short getDeleted() {
        return deleted;
    }

    /**
     * @param deleted 逻辑删除字段
     */
    public void setDeleted(Short deleted) {
        this.deleted = deleted;
    }

    /**
     * @return 版本
     */
    public Short getVersion() {
        return version;
    }

    /**
     * @param version 版本
     */
    public void setVersion(Short version) {
        this.version = version;
    }

    /**
     * @return 是否是最新数据，0：最新数据；1：历史数据
     */
    public Short getIsNewest() {
        return isNewest;
    }

    /**
     * @param isNewest 是否是最新数据，0：最新数据；1：历史数据
     */
    public void setIsNewest(Short isNewest) {
        this.isNewest = isNewest;
    }

    /**
     * @return 数据状态
     */
    public String getDataStated() {
        return dataStated;
    }

    /**
     * @param dataStated 数据状态
     */
    public void setDataStated(String dataStated) {
        this.dataStated = dataStated == null ? null : dataStated.trim();
    }


    /**
     * @return 所属管道
     */
    public String getPipeLineId() {
        return pipeLineId;
    }

    /**
     * @param pipeLineId 所属管道
     */
    public void setPipeLineId(String pipeLineId) {
        this.pipeLineId = pipeLineId == null ? null : pipeLineId.trim();
    }

    /**
     * @return 所属管道名称
     */
    public String getPipeName() {
        return pipeName;
    }

    /**
     * @param pipeName 所属管道名称
     */
    public void setPipeName(String pipeName) {
        this.pipeName = pipeName == null ? null : pipeName.trim();
    }

    /**
     * @return 统一编号
     */
    public String getCode() {
        return code;
    }

    /**
     * @param code 统一编号
     */
    public void setCode(String code) {
        this.code = code == null ? null : code.trim();
    }

    /**
     * @return 设备编号(自定义编号)
     */
    public String getCustomNumber() {
        return customNumber;
    }

    /**
     * @param customNumber 设备编号(自定义编号)
     */
    public void setCustomNumber(String customNumber) {
        this.customNumber = customNumber == null ? null : customNumber.trim();
    }

    /**
     * @return 干扰源名称
     */
    public String getName() {
        return name;
    }

    /**
     * @param name 干扰源名称
     */
    public void setName(String name) {
        this.name = name == null ? null : name.trim();
    }

    /**
     * @return 相对位置关系(平行PARALLEL、交叉ACROSS)
     */
    public String getRelativePositionRelation() {
        if (InfluencePositionEnum.PARALLEL.toString().equals(this.relativePositionRelation)) {
            return "平行";
        } else if (InfluencePositionEnum.ACROSS.toString().equals(this.relativePositionRelation)) {
            return "交叉";
        }
        return null;
    }

    /**
     * @param relativePositionRelation 相对位置关系(平行PARALLEL、交叉ACROSS)
     */
    public void setRelativePositionRelation(String relativePositionRelation) {
        this.relativePositionRelation = relativePositionRelation == null ? null : relativePositionRelation.trim();
    }

    /**
     * @return GISID
     */
    public String getGisid() {
        return gisid;
    }

    /**
     * @param gisid GISID
     */
    public void setGisid(String gisid) {
        this.gisid = gisid == null ? null : gisid.trim();
    }

    /**
     * @return 平行段起点_绝对里程
     */
    public String getBeginMileage() {
        return transformNum(beginMileage);
    }

    /**
     * @param beginMileage 平行段起点_绝对里程
     */
    public void setBeginMileage(String beginMileage) {
        this.beginMileage = beginMileage;
    }

    /**
     * @return 平行起点_附近测试桩
     */
    public String getBeginNagm() {
        return beginNagm;
    }

    /**
     * @param beginNagm 平行起点_附近测试桩
     */
    public void setBeginNagm(String beginNagm) {
        this.beginNagm = beginNagm == null ? null : beginNagm.trim();
    }

    /**
     * @return 平行起点_附近测试桩距离
     */
    public String getBeginNagmMileage() {
        return transformNum(beginNagmMileage);
    }

    /**
     * @param beginNagmMileage 平行起点_附近测试桩距离
     */
    public void setBeginNagmMileage(String beginNagmMileage) {
        this.beginNagmMileage = beginNagmMileage;
    }

    /**
     * @return 平行段终点_绝对里程
     */
    public String getEndMileage() {
        return transformNum(endMileage);
    }

    /**
     * @param endMileage 平行段终点_绝对里程
     */
    public void setEndMileage(String endMileage) {
        this.endMileage = endMileage;
    }

    /**
     * @return 平行段终点_附近测试桩
     */
    public String getEndNagm() {

        return endNagm;
    }

    /**
     * @param endNagm 平行段终点_附近测试桩
     */
    public void setEndNagm(String endNagm) {
        this.endNagm = endNagm == null ? null : endNagm.trim();
    }

    /**
     * @return 平行段终点_附近测试桩距离
     */
    public String getEndNagmMileage() {
        return transformNum(endNagmMileage);
    }

    /**
     * @param endNagmMileage 平行段终点_附近测试桩距离
     */
    public void setEndNagmMileage(String endNagmMileage) {
        this.endNagmMileage = endNagmMileage;
    }

    /**
     * @return 最小平行间距
     * （m）
     */
    public BigDecimal getMinDistance() {
        return minDistance;
    }

    /**
     * @param minDistance 最小平行间距
     *                    （m）
     */
    public void setMinDistance(BigDecimal minDistance) {
        this.minDistance = minDistance;
    }

    /**
     * 平行长度（由系统计算）
     *
     * @return
     */
    public BigDecimal getParallelMileage() {
        if (this.beginMileage != null && this.endMileage != null) {
            return parallelMileage = new BigDecimal(Long.parseLong(this.endMileage) - Long.parseLong(this.beginMileage)).
                    divide(new BigDecimal(1000)).setScale(3, BigDecimal.ROUND_DOWN);
        } else {
            return null;
        }
    }

    /**
     * 平行长度（由系统计算）
     *
     * @return
     */
    public void setParallelMileage(BigDecimal parallelMileage) {
        this.parallelMileage = parallelMileage;
    }

    /**
     * @return 交叉段_绝对里程
     */
    public String getCrossMileage() {

        return transformNum(crossMileage);
    }

    /**
     * @param crossMileage 交叉段_绝对里程
     */
    public void setCrossMileage(String crossMileage) {
        this.crossMileage = crossMileage;
    }

    /**
     * @return 交叉段_附近测试桩
     */
    public String getCrossNagm() {

        return crossNagm;
    }

    /**
     * @param crossNagm 交叉段_附近测试桩
     */
    public void setCrossNagm(String crossNagm) {
        this.crossNagm = crossNagm == null ? null : crossNagm.trim();
    }

    /**
     * @return 交叉段_附近测试桩距离
     */
    public String getCrossNagmMileage() {

        return transformNum(crossNagmMileage);
    }

    /**
     * @param crossNagmMileage 交叉段_附近测试桩距离
     */
    public void setCrossNagmMileage(String crossNagmMileage) {
        this.crossNagmMileage = crossNagmMileage;
    }

    /**
     * @return 位置描述
     */
    public String getLocationDescription() {
        return locationDescription;
    }

    /**
     * @param locationDescription 位置描述
     */
    public void setLocationDescription(String locationDescription) {
        this.locationDescription = locationDescription == null ? null : locationDescription.trim();
    }

    /**
     * @return 投用日期
     */
    public Date getInserviceDate() {
        return inserviceDate;
    }

    /**
     * @param inserviceDate 投用日期
     */
    public void setInserviceDate(Date inserviceDate) {
        this.inserviceDate = inserviceDate;
    }

    /**
     * @return 供电方式
     */
    public String getPowerSupplyMode() {
        return powerSupplyMode;
    }

    /**
     * @param powerSupplyMode 供电方式
     */
    public void setPowerSupplyMode(String powerSupplyMode) {
        this.powerSupplyMode = powerSupplyMode == null ? null : powerSupplyMode.trim();
    }

    /**
     * @return 馈电方式
     */
    public String getFeedMode() {
        return feedMode;
    }

    /**
     * @param feedMode 馈电方式
     */
    public void setFeedMode(String feedMode) {
        this.feedMode = feedMode == null ? null : feedMode.trim();
    }

    /**
     * @return 馈电极性
     */
    public String getFeedElectrodeProperty() {
        return feedElectrodeProperty;
    }

    /**
     * @param feedElectrodeProperty 馈电极性
     */
    public void setFeedElectrodeProperty(String feedElectrodeProperty) {
        this.feedElectrodeProperty = feedElectrodeProperty == null ? null : feedElectrodeProperty.trim();
    }

    /**
     * @return 牵引电流（A）
     */
    public Long getTractionCurrent() {
        return tractionCurrent;
    }

    /**
     * @param tractionCurrent 牵引电流（A）
     */
    public void setTractionCurrent(Long tractionCurrent) {
        this.tractionCurrent = tractionCurrent;
    }

    /**
     * @return 牵引变电所_X
     */
    public BigDecimal getSubstationX() {
        return substationX;
    }

    /**
     * @param substationX 牵引变电所_X
     */
    public void setSubstationX(BigDecimal substationX) {
        this.substationX = substationX;
    }

    /**
     * @return 牵引变电所_Y
     */
    public BigDecimal getSubstationY() {
        return substationY;
    }

    /**
     * @param substationY 牵引变电所_Y
     */
    public void setSubstationY(BigDecimal substationY) {
        this.substationY = substationY;
    }

    /**
     * @return 牵引变电所_Z
     */
    public BigDecimal getSubstationZ() {
        return substationZ;
    }

    /**
     * @param substationZ 牵引变电所_Z
     */
    public void setSubstationZ(BigDecimal substationZ) {
        this.substationZ = substationZ;
    }

    /**
     * @return 牵引变电所_附近测试桩
     */
    public String getSubstationNagm() {
        return substationNagm;
    }

    /**
     * @param substationNagm 牵引变电所_附近测试桩
     */
    public void setSubstationNagm(String substationNagm) {
        this.substationNagm = substationNagm == null ? null : substationNagm.trim();
    }

    /**
     * @return 牵引变电所_附近测试桩距离
     */
    public Long getSubstationNagmMileage() {
        return substationNagmMileage;
    }

    /**
     * @param substationNagmMileage 牵引变电所_附近测试桩距离
     */
    public void setSubstationNagmMileage(Long substationNagmMileage) {
        this.substationNagmMileage = substationNagmMileage;
    }

    /**
     * @return 牵引变电所_绝对里程
     */
    public Long getSubstationMileage() {
        return substationMileage;
    }

    /**
     * @param substationMileage 牵引变电所_绝对里程
     */
    public void setSubstationMileage(Long substationMileage) {
        this.substationMileage = substationMileage;
    }

    /**
     * @return 距管道最小距离（m）
     */
    public BigDecimal getMinDistanceFromPipe() {
        return minDistanceFromPipe;
    }

    /**
     * @param minDistanceFromPipe 距管道最小距离（m）
     */
    public void setMinDistanceFromPipe(BigDecimal minDistanceFromPipe) {
        this.minDistanceFromPipe = minDistanceFromPipe;
    }

    /**
     * @return 牵引变电所位置描述
     */
    public String getSubstationLocationDesc() {
        return substationLocationDesc;
    }

    /**
     * @param substationLocationDesc 牵引变电所位置描述
     */
    public void setSubstationLocationDesc(String substationLocationDesc) {
        this.substationLocationDesc = substationLocationDesc == null ? null : substationLocationDesc.trim();
    }

    /**
     * @return 电车运行状况
     */
    public String getRunningStatusOfTram() {
        return runningStatusOfTram;
    }

    /**
     * @param runningStatusOfTram 电车运行状况
     */
    public void setRunningStatusOfTram(String runningStatusOfTram) {
        this.runningStatusOfTram = runningStatusOfTram == null ? null : runningStatusOfTram.trim();
    }

    /**
     * @return 检测单位
     */
    public String getTestingCompany() {
        return testingCompany;
    }

    /**
     * @param testingCompany 检测单位
     */
    public void setTestingCompany(String testingCompany) {
        this.testingCompany = testingCompany == null ? null : testingCompany.trim();
    }

    /**
     * @return 检测日期
     */
    public Date getTestingDate() {
        return testingDate;
    }

    /**
     * @param testingDate 检测日期
     */
    public void setTestingDate(Date testingDate) {
        this.testingDate = testingDate;
    }

    /**
     * @return 记录人（直接存名称）
     */
    public String getRecorder() {
        return recorder;
    }

    /**
     * @param recorder 记录人（直接存名称）
     */
    public void setRecorder(String recorder) {
        this.recorder = recorder == null ? null : recorder.trim();
    }

    /**
     * @return 记录时间
     */
    public Date getRecordTime() {
//        if (this.recordTime != null) {
//            return recordTime;
//        } else {
//            return recordTime = new Date();
//        }
        return  recordTime;
    }

    /**
     * @param recordTime 记录时间
     */
    public void setRecordTime(Date recordTime) {
        this.recordTime = recordTime;
    }

    /**
     * @return 备注
     */
    public String getRemarks() {
        return remarks;
    }

    /**
     * @param remarks 备注
     */
    public void setRemarks(String remarks) {
        this.remarks = remarks == null ? null : remarks.trim();
    }

    /**
     * @return 业务组织路径
     */
    public String getOrgBizPath() {
        return orgBizPath;
    }

    /**
     * @param orgBizPath 业务组织路径
     */
    public void setOrgBizPath(String orgBizPath) {
        this.orgBizPath = orgBizPath == null ? null : orgBizPath.trim();
    }

    public String getPipeGisId() {
        return pipeGisId;
    }

    public void setPipeGisId(String pipeGisId) {
        this.pipeGisId = pipeGisId;
    }

    public String getPbeginNgm() {
        return pbeginNgm;
    }

    public void setPbeginNgm(String pbeginNgm) {
        this.pbeginNgm = pbeginNgm;
    }

    public String getPendNgm() {
        return pendNgm;
    }

    public void setPendNgm(String pendNgm) {
        this.pendNgm = pendNgm;
    }

    public String getCrossNgm() {
        return crossNgm;
    }

    public void setCrossNgm(String crossNgm) {
        this.crossNgm = crossNgm;
    }

    /**
     * 用string处理数据保持精度的正确（转化为3位小数）
     *
     * @param mileage
     * @return
     */
    private String transformNum(String mileage) {
        if (mileage != null) {
            return new BigDecimal(mileage).divide(new BigDecimal(1000)).setScale(3, BigDecimal.ROUND_DOWN).stripTrailingZeros().toPlainString();
        } else {
            return null;
        }
    }


}
